#include"head.h"

int logout_user(int net_fd, MYSQL* connection){


    char token[256] = {0};
    int token_len = 0;

    recv(net_fd, &token_len, sizeof(int), 0);
    recv(net_fd, &token, token_len, 0);


    char* user_name = decode_token(token);

    utils_remove_file(connection, user_name, user_name);

    bool stat = utils_logout(connection, user_name);

    if(stat){
        free(user_name);

        int s = 1;
        send(net_fd, &s, sizeof(int), MSG_NOSIGNAL);
        close(net_fd);
        return 0;
    }

    int s = 0;
    send(net_fd, &s, sizeof(int), MSG_NOSIGNAL);
    return 0;
}
